Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-visit

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-visit

Call a specified method on each value in the given object.

  • 0.3.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.1M
decreased by-4.9%
Maintainers
1
Weekly downloads
 
Created

What is object-visit?

The object-visit npm package is designed to simplify the process of visiting and invoking methods on an object. It allows you to call a specified method on each property of an object, which can be particularly useful for tasks like data transformation, validation, or applying a series of operations to an object's properties.

What are object-visit's main functionalities?

Invoke a method on each property of an object

This feature allows you to invoke a specified method on each property of an object. In this example, the 'greet' method is called on each property of the object, transforming the 'greet' property to its return value.

const visit = require('object-visit');

const obj = {
  name: 'John',
  age: 30,
  greet: function() { return `Hello, my name is ${this.name}`; }
};

visit(obj, 'greet');
// Output: { name: 'John', age: 30, greet: 'Hello, my name is John' }

Invoke a method with arguments on each property of an object

This feature allows you to invoke a specified method with arguments on each property of an object. In this example, the 'greet' method is called with the argument 'Hi' on each property of the object, transforming the 'greet' property to its return value.

const visit = require('object-visit');

const obj = {
  name: 'John',
  age: 30,
  greet: function(greeting) { return `${greeting}, my name is ${this.name}`; }
};

visit(obj, 'greet', 'Hi');
// Output: { name: 'John', age: 30, greet: 'Hi, my name is John' }

Other packages similar to object-visit

Keywords

FAQs

Package last updated on 09 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc